IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_schoolverloopBelangstellingstest' AND xtype='P') 
BEGIN
	DROP PROCEDURE WEB_schoolverloopBelangstellingstest
END
GO

CREATE   procedure WEB_schoolverloopBelangstellingstest
(@hoofdNr int, @iNr char(7))
as
set nocount on
select @hoofdNr,1,case when inschrijvingsNr is not null then
  '<belangstelling datum="' + isNull(convert(varchar(15),datum,103),'') + '">' +
        isNull('<eco>' + convert(varchar(5),eco) + '</eco>','') +
        isNull('<fij>' + convert(varchar(5),fij) + '</fij>','') +
        isNull('<gez>' + convert(varchar(5),gez) + '</gez>','') +
        isNull('<kle>' + convert(varchar(5),kle) + '</kle>','') +
        isNull('<hwe>' + convert(varchar(5),hwe) + '</hwe>','') +
        isNull('<lan>' + convert(varchar(5),lan) + '</lan>','') +
        isNull('<los>' + convert(varchar(5),los) + '</los>','') +
        isNull('<ont>' + convert(varchar(5),ont) + '</ont>','') +         
        isNull('<pod>' + convert(varchar(5),pod) + '</pod>','') +
        isNull('<prt>' + convert(varchar(5),prt) + '</prt>','') +
        isNull('<sch>' + convert(varchar(5),sch) + '</sch>','') +
        isNull('<sie>' + convert(varchar(5),sie) + '</sie>','') +
        isNull('<bek>' + convert(varchar(5),bek) + '</bek>','') +
        isNull('<toe>' + convert(varchar(5),toe) + '</toe>','') +
        isNull('<sod>' + convert(varchar(5),sod) + '</sod>','') +
        isNull('<per>' + convert(varchar(5),per) + '</per>','') +
        isNull('<tal>' + convert(varchar(5),tal) + '</tal>','') +
        isNull('<tht>' + convert(varchar(5),tht) + '</tht>','') +
        isNull('<voe>' + convert(varchar(5),voe) + '</voe>','') +
        isNull('<wet>' + convert(varchar(5),wet) + '</wet>','') +
        isNull('<wis>' + convert(varchar(5),wis) + '</wis>','') +
  '</belangstelling>'
  else '' end
from belangstellingstest where inschrijvingsNr = @iNr